package com.example.mybatisdemo.servicd;

import com.example.mybatisdemo.mapper.UserMapper;
import com.example.mybatisdemo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName UserService
 * @Description TODO
 * @Author xiaoying
 * @Date 2022/8/29 14:24
 * @Version V1.0.0
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    @Transactional
  public User queryBuId(){
      User user = userMapper.queryById(1);
      user.setAge(80);
      userMapper.update(user);
      User user1 = userMapper.queryById(1);
      System.out.println(user);
      System.out.println(user1);
      return user1;
  }
}
